import("//llvm/tools/binutils_symlinks.gni")
import("//llvm/utils/gn/build/symlink_or_copy.gni")

symlinks = [
  "llvm-dlltool",
  "llvm-lib",
  "llvm-ranlib",
]
if (llvm_install_binutils_symlinks) {
  symlinks += [
    "ar",
    "dlltool",
    "ranlib",
  ]
}
foreach(target, symlinks) {
  symlink_or_copy(target) {
    deps = [ ":llvm-ar" ]
    source = "llvm-ar"
    output = "$root_out_dir/bin/$target"
  }
}

# //:llvm-ar depends on this symlink target, see comment in //BUILD.gn.
group("symlinks") {
  deps = []
  foreach(target, symlinks) {
    deps += [ ":$target" ]
  }
}

executable("llvm-ar") {
  deps = [
    "//llvm/lib/IR",
    "//llvm/lib/Object",
    "//llvm/lib/Support",
    "//llvm/lib/Target:TargetsToBuild",
    "//llvm/lib/ToolDrivers/llvm-dlltool:DlltoolDriver",
    "//llvm/lib/ToolDrivers/llvm-lib:LibDriver",
  ]
  sources = [ "llvm-ar.cpp" ]
}
